/*
 * @lc app=leetcode.cn id=1859 lang=javascript
 *
 * [1859] 将句子排序
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var sortSentence = function (s) {
  return s.split(' ')
    .map(word => [word.slice(0, word.length - 1), +word.slice(word.length - 1)])
    .sort(([_1, idx1], [_2, idx2]) => idx1 - idx2)
    .map(([word]) => word)
    .join(' ');
};
// @lc code=end

